package vista;

import java.awt.BorderLayout;
import javax.swing.ComboBoxModel;
import javax.swing.DefaultComboBoxModel;
import javax.swing.GroupLayout;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JComponent;
import javax.swing.JLabel;
import javax.swing.JList;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.LayoutStyle;
import javax.swing.ListModel;

import javax.swing.WindowConstants;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
import javax.swing.SwingUtilities;

import modelo.Categoria;

import java.awt.event.ActionListener;
import java.util.List;

/**
* This code was edited or generated using CloudGarden's Jigloo
* SWT/Swing GUI Builder, which is free for non-commercial
* use. If Jigloo is being used commercially (ie, by a corporation,
* company or business for any purpose whatever) then you
* should purchase a license for each developer using Jigloo.
* Please visit www.cloudgarden.com for details.
* Use of Jigloo implies acceptance of these licensing terms.
* A COMMERCIAL LICENSE HAS NOT BEEN PURCHASED FOR
* THIS MACHINE, SO JIGLOO OR THIS CODE CANNOT BE USED
* LEGALLY FOR ANY CORPORATE OR COMMERCIAL PURPOSE.
*/
public class VistaProducto extends javax.swing.JFrame {
	private JPanel jPanelproductos;
	private JLabel jLblCodProducto;
	private JList jListProductoxIngrediente;
	private JScrollPane jScrollPaneProdIngre;
	private JButton jBtnRemover;
	private JTextField jTxtCant;
	private JLabel jLblCant;
	private JTextField jTxtCodIngre;
	private JLabel jLblCodIngre;
	private JButton jBtnLimpiarProd;
	private JButton jBtnEliminarProd;
	private JButton jBtnModificarProd;
	private JButton jBtnRegistrarProd;
	private JButton jBtnBuscarProd;
	private JTextField jTxtPrecio;
	private JButton jBtnAgregar;
	private JLabel jLblPrecio;
	private JTextField jTxtNombProd;
	private JTextField jTxtCodProd;
	private JComboBox jCmbCategoria;
	private JLabel jLblIngredientes;
	private JLabel jLblNombProduc;
	private JLabel jLblCmbCategoria;
	private JPanel jPanelProductos;

	/**
	* Auto-generated main method to display this JFrame
	*/
	public static void main(String[] args) {
		SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				VistaProducto inst = new VistaProducto();
				inst.setLocationRelativeTo(null);
				inst.setVisible(true);
			}
		});
	}
	
	public VistaProducto() {
		super();
		initGUI();
		
	}
	
	private void initGUI() {
		try {
			GroupLayout thisLayout = new GroupLayout((JComponent)getContentPane());
			getContentPane().setLayout(thisLayout);
			setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
			this.setTitle("-SGECR- [Modulo de Archivos] - Gestión de Productos");
			getContentPane().setBackground(new java.awt.Color(93,193,225));
			{
				jPanelproductos = new JPanel();
			}
			{
				jPanelProductos = new JPanel();
				GroupLayout jPanelProductosLayout = new GroupLayout((JComponent)jPanelProductos);
				jPanelProductos.setLayout(jPanelProductosLayout);
				jPanelProductos.setBackground(new java.awt.Color(173,216,230));
				{
					jLblCodProducto = new JLabel();
					jLblCodProducto.setText("Cod. Producto:");
				}
				{
					jLblNombProduc = new JLabel();
					jLblNombProduc.setText("Nombre:");
				}
				{
					jLblIngredientes = new JLabel();
					jLblIngredientes.setText("-Ingredientes Requeridos-");
					jLblIngredientes.setFont(new java.awt.Font("Bitstream Charter",0,14));
				}
				{
					jBtnAgregar = new JButton();
					jBtnAgregar.setText("Agregar");
				}
				{
					jLblCant = new JLabel();
					jLblCant.setText("Cantidad:");
				}
				{
					jTxtCant = new JTextField();
				}
				{
					jLblCodIngre = new JLabel();
					jLblCodIngre.setText("Cod. Ingrediente: ");
				}
				{
					jScrollPaneProdIngre = new JScrollPane();
					{
						ListModel jListProductoxIngredienteModel = 
							new DefaultComboBoxModel(
									new String[] { "", "", "" });
						jListProductoxIngrediente = new JList();
						jScrollPaneProdIngre.setViewportView(jListProductoxIngrediente);
						jListProductoxIngrediente.setModel(jListProductoxIngredienteModel);
					}
				}
				{
					jBtnRemover = new JButton();
					jBtnRemover.setText("Remover");
				}
				{
					jTxtCodIngre = new JTextField();
				}
				{
					jLblPrecio = new JLabel();
					jLblPrecio.setText("Precio Bs.F:");
				}
				{
					jTxtPrecio = new JTextField();
				}
				{
					jBtnBuscarProd = new JButton();
					jBtnBuscarProd.setText("Buscar");
				}
				{
					jBtnRegistrarProd = new JButton();
					jBtnRegistrarProd.setText("Registrar");
				}
				{
					jBtnModificarProd = new JButton();
					jBtnModificarProd.setText("Modificar");
				}
				{
					jBtnEliminarProd = new JButton();
					jBtnEliminarProd.setText("Eliminar");
				}
				{
					jBtnLimpiarProd = new JButton();
					jBtnLimpiarProd.setText("Limpiar");
				}
				{
					jLblCmbCategoria = new JLabel();
					jLblCmbCategoria.setText("Categoria: ");
				}
				{
					/*ComboBoxModel jCmbCategoriaModel = 
						new DefaultComboBoxModel(
								new String[] { "Hamburguesa", "Pepito", "Perro Caliente" });*/
					jCmbCategoria = new JComboBox();
					jPanelProductos.add(jCmbCategoria);
					//setCargarComboCategoria(List<Categoria> categoria)
					//jCmbCategoria.setModel(jCmbCategoriaModel);
					
					//setCargarComboCategoria(Object[] categorias)
					
					
				}
				{
					jTxtCodProd = new JTextField();
				}
				{
					jTxtNombProd = new JTextField();
				}
					jPanelProductosLayout.setVerticalGroup(jPanelProductosLayout.createSequentialGroup()
					.addContainerGap(26, 26)
					.addGroup(jPanelProductosLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					    .addComponent(jCmbCategoria, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					    .addComponent(jLblCodProducto, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					    .addComponent(jTxtCodProd, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					    .addComponent(jBtnBuscarProd, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					    .addComponent(jLblCmbCategoria, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(22)
					.addGroup(jPanelProductosLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					    .addComponent(jTxtNombProd, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					    .addComponent(jLblNombProduc, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(42)
					.addComponent(jLblIngredientes, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					.addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					.addGroup(jPanelProductosLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					    .addComponent(jTxtCant, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					    .addComponent(jLblCant, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					    .addComponent(jTxtCodIngre, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					    .addComponent(jLblCodIngre, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addGap(21)
					.addGroup(jPanelProductosLayout.createParallelGroup()
					    .addGroup(GroupLayout.Alignment.LEADING, jPanelProductosLayout.createSequentialGroup()
					        .addGroup(jPanelProductosLayout.createParallelGroup()
					            .addGroup(GroupLayout.Alignment.LEADING, jPanelProductosLayout.createSequentialGroup()
					                .addGap(0, 0, Short.MAX_VALUE)
					                .addComponent(jBtnRegistrarProd, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE)
					                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					                .addComponent(jBtnModificarProd, GroupLayout.PREFERRED_SIZE, 28, GroupLayout.PREFERRED_SIZE))
					            .addGroup(GroupLayout.Alignment.LEADING, jPanelProductosLayout.createSequentialGroup()
					                .addGap(0, 13, Short.MAX_VALUE)
					                .addComponent(jBtnAgregar, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 0, GroupLayout.PREFERRED_SIZE)
					                .addComponent(jBtnRemover, GroupLayout.PREFERRED_SIZE, 21, GroupLayout.PREFERRED_SIZE)))
					        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					        .addComponent(jBtnEliminarProd, GroupLayout.PREFERRED_SIZE, 27, GroupLayout.PREFERRED_SIZE)
					        .addComponent(jBtnLimpiarProd, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE))
					    .addGroup(GroupLayout.Alignment.LEADING, jPanelProductosLayout.createSequentialGroup()
					        .addComponent(jScrollPaneProdIngre, GroupLayout.PREFERRED_SIZE, 105, GroupLayout.PREFERRED_SIZE)
					        .addGap(0, 19, Short.MAX_VALUE)))
					.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED, 20, GroupLayout.PREFERRED_SIZE)
					.addGroup(jPanelProductosLayout.createParallelGroup(GroupLayout.Alignment.BASELINE)
					    .addComponent(jTxtPrecio, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE)
					    .addComponent(jLblPrecio, GroupLayout.Alignment.BASELINE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))
					.addContainerGap(50, 50));
					jPanelProductosLayout.setHorizontalGroup(jPanelProductosLayout.createSequentialGroup()
					.addContainerGap(20, 20)
					.addGroup(jPanelProductosLayout.createParallelGroup()
					    .addGroup(jPanelProductosLayout.createSequentialGroup()
					        .addGroup(jPanelProductosLayout.createParallelGroup()
					            .addGroup(GroupLayout.Alignment.LEADING, jPanelProductosLayout.createSequentialGroup()
					                .addComponent(jLblCodIngre, GroupLayout.PREFERRED_SIZE, 128, GroupLayout.PREFERRED_SIZE)
					                .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					                .addGroup(jPanelProductosLayout.createParallelGroup()
					                    .addGroup(GroupLayout.Alignment.LEADING, jPanelProductosLayout.createSequentialGroup()
					                        .addComponent(jTxtCodIngre, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)
					                        .addGap(0, 152, GroupLayout.PREFERRED_SIZE))
					                    .addGroup(GroupLayout.Alignment.LEADING, jPanelProductosLayout.createSequentialGroup()
					                        .addGap(0, 65, GroupLayout.PREFERRED_SIZE)
					                        .addComponent(jLblIngredientes, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE, GroupLayout.PREFERRED_SIZE))))
					            .addGroup(jPanelProductosLayout.createSequentialGroup()
					                .addGroup(jPanelProductosLayout.createParallelGroup()
					                    .addComponent(jLblCmbCategoria, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE)
					                    .addComponent(jLblNombProduc, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE))
					                .addGap(7)
					                .addGroup(jPanelProductosLayout.createParallelGroup()
					                    .addComponent(jTxtNombProd, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 117, GroupLayout.PREFERRED_SIZE)
					                    .addComponent(jCmbCategoria, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 117, GroupLayout.PREFERRED_SIZE))
					                .addGap(147)))
					        .addComponent(jTxtCodProd, GroupLayout.PREFERRED_SIZE, 114, GroupLayout.PREFERRED_SIZE)
					        .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
					        .addComponent(jBtnBuscarProd, GroupLayout.PREFERRED_SIZE, 76, GroupLayout.PREFERRED_SIZE))
					    .addGroup(jPanelProductosLayout.createSequentialGroup()
					        .addGap(8)
					        .addGroup(jPanelProductosLayout.createParallelGroup()
					            .addGroup(GroupLayout.Alignment.LEADING, jPanelProductosLayout.createSequentialGroup()
					                .addComponent(jLblPrecio, GroupLayout.PREFERRED_SIZE, 93, GroupLayout.PREFERRED_SIZE)
					                .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
					                .addComponent(jTxtPrecio, GroupLayout.PREFERRED_SIZE, 117, GroupLayout.PREFERRED_SIZE)
					                .addGroup(jPanelProductosLayout.createParallelGroup()
					                    .addGroup(GroupLayout.Alignment.LEADING, jPanelProductosLayout.createSequentialGroup()
					                        .addComponent(jLblCant, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)
					                        .addGap(0, 56, Short.MAX_VALUE))
					                    .addGroup(jPanelProductosLayout.createSequentialGroup()
					                        .addGap(0, 25, Short.MAX_VALUE)
					                        .addComponent(jLblCodProducto, GroupLayout.PREFERRED_SIZE, 103, GroupLayout.PREFERRED_SIZE)))
					                .addGap(57))
					            .addGroup(GroupLayout.Alignment.LEADING, jPanelProductosLayout.createSequentialGroup()
					                .addPreferredGap(jLblPrecio, jScrollPaneProdIngre, LayoutStyle.ComponentPlacement.INDENT)
					                .addComponent(jScrollPaneProdIngre, GroupLayout.PREFERRED_SIZE, 289, GroupLayout.PREFERRED_SIZE)
					                .addGap(11)
					                .addGroup(jPanelProductosLayout.createParallelGroup()
					                    .addGroup(GroupLayout.Alignment.LEADING, jPanelProductosLayout.createSequentialGroup()
					                        .addComponent(jTxtCant, GroupLayout.PREFERRED_SIZE, 72, GroupLayout.PREFERRED_SIZE)
					                        .addGap(0, 29, Short.MAX_VALUE))
					                    .addGroup(jPanelProductosLayout.createSequentialGroup()
					                        .addPreferredGap(jTxtCant, jBtnRemover, LayoutStyle.ComponentPlacement.INDENT)
					                        .addGroup(jPanelProductosLayout.createParallelGroup()
					                            .addComponent(jBtnRemover, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE)
					                            .addComponent(jBtnAgregar, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 88, GroupLayout.PREFERRED_SIZE))))))
					        .addGap(30)
					        .addGroup(jPanelProductosLayout.createParallelGroup()
					            .addComponent(jBtnRegistrarProd, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 97, GroupLayout.PREFERRED_SIZE)
					            .addComponent(jBtnEliminarProd, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 97, GroupLayout.PREFERRED_SIZE)
					            .addComponent(jBtnModificarProd, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 97, GroupLayout.PREFERRED_SIZE)
					            .addComponent(jBtnLimpiarProd, GroupLayout.Alignment.LEADING, GroupLayout.PREFERRED_SIZE, 97, GroupLayout.PREFERRED_SIZE))
					        .addGap(13)))
					.addContainerGap(19, 19));
			}
			thisLayout.setVerticalGroup(thisLayout.createSequentialGroup()
				.addContainerGap(19, 19)
				.addGroup(thisLayout.createParallelGroup()
				    .addGroup(thisLayout.createSequentialGroup()
				        .addComponent(jPanelProductos, GroupLayout.PREFERRED_SIZE, 421, GroupLayout.PREFERRED_SIZE)
				        .addGap(0, 0, Short.MAX_VALUE))
				    .addGroup(GroupLayout.Alignment.LEADING, thisLayout.createSequentialGroup()
				        .addGap(55)
				        .addComponent(jPanelproductos, GroupLayout.PREFERRED_SIZE, 10, GroupLayout.PREFERRED_SIZE)
				        .addGap(0, 356, Short.MAX_VALUE)))
				.addContainerGap(60, 60));
			thisLayout.setHorizontalGroup(thisLayout.createSequentialGroup()
				.addContainerGap(24, 24)
				.addComponent(jPanelProductos, 0, 600, Short.MAX_VALUE)
				.addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
				.addComponent(jPanelproductos, GroupLayout.PREFERRED_SIZE, 10, GroupLayout.PREFERRED_SIZE)
				.addContainerGap(16, 16));
			pack();
			this.setSize(666, 530);
		} catch (Exception e) {
		    //add your error handling code here
			e.printStackTrace();
		}
	}
	
	

	public void addListener(ActionListener actionlistener)
	{
		jBtnBuscarProd.addActionListener(actionlistener);
		jBtnRegistrarProd.addActionListener(actionlistener);
		jBtnModificarProd.addActionListener(actionlistener);
		jBtnEliminarProd.addActionListener(actionlistener);
		jBtnLimpiarProd.addActionListener(actionlistener);
		jBtnAgregar.addActionListener(actionlistener);
		jBtnRemover.addActionListener(actionlistener);

	}
	
	public void MostrarMensaje(String mensaje)
	{
		JOptionPane.showMessageDialog(this, mensaje);
	}
	
	public String getCategoria()
	{
	 return jCmbCategoria.getName();
	 
	}
	public String getCodProducto()
	{
	 return jTxtCodProd.getText();
	 
	}
	public String getNombProducto()
	{
	 return jTxtNombProd.getText();
	}
	
	public float getPrecio()
	{
	 return Float.valueOf(jTxtPrecio.getText().trim()).floatValue();
	 
	}
	public float getCantidad()
	{
		 return Float.valueOf(jTxtCant.getText().trim());
	}
	public String CodIngre()
	{
		return  jTxtCodIngre.getText();
	}
	 
	public void setCodIngre(String cod)
	{
		jTxtCodIngre.setText(cod);
	}
	public void setCant(float cant)
	{
		jTxtCant.setText(String.valueOf(cant));
	}
	public void setCodCategoria(String codcat)
	{
		jCmbCategoria.setName(codcat);
	}
	public void setCodProducto(String cod)
	{
	 jTxtCodProd.setText(cod);
	 
	}
	public void setNombProducto(String nom)
	{
	  jTxtNombProd.setText(nom);
	}
	
	public void setPrecio(float pre)
	{
	 jTxtPrecio.setText(String.valueOf(pre));
	}
	public void Blanquear()
	{
		jCmbCategoria.setName("");
		jTxtCodProd.setText("");
		jTxtNombProd.setText("");
		jTxtPrecio.setText("");
		jTxtCodIngre.setText("");
		jTxtCant.setText("");
	}
	
	public void setCargarComboCategoria(List categoria)
	{
		ComboBoxModel cmbCategoriasModel =
            new DefaultComboBoxModel(categoria.toArray());
        jCmbCategoria.setModel(cmbCategoriasModel);
	}
	
}